<?php

class Catalogo_model extends CI_Model {

    public function construct() {
        parent::__construct();
    }

     public function verCliente($params) {
       
        $sql = "call usp_ventverCliente(?)";
        
        return  $this->db->query($sql, $params);
    }
      public function verventa($params) {
        $sql = "call usp_ventpverventa(?)";
        $query = $this->db->query($sql, $params);     
        if ($query->num_rows() > 0) {
            foreach ($query->result() as $fila) :
                $data[] = $fila;
            endforeach;
        }else {
            $data = null;
        }
        return $data;
        
    }
        
    public function filtrarVenta($params) {
        $sql = "call usp_ventpbuscarpedido(?,?)";
        $query = $this->db->query($sql, $params);
        if ($query->num_rows() > 0) {
            foreach ($query->result() as $fila) :
                $data[] = $fila;
            endforeach;
        }else {
            $data = null;
        }
        return $data;
    }
   ////////////////////////////////////////////////////////////// 
    public function filtrarClientes($params) {
        $sql = "call sp_IEcliente(?,?)";
        $query = $this->db->query($sql, $params);
        if ($query->num_rows() > 0) {
            foreach ($query->result() as $fila) :
                $data[] = $fila;
            endforeach;
        }else {
            $data = null;
        }
        return $data;
    }
            
    function listar_prod($id,$idsuc,$col,$alm) {
        $sql = "call sp_BProd($id,$idsuc,$col,$alm)";
        $productos = $this->db->query($sql);
        foreach ($productos->result() as $producto) {
            $data[] = $producto;
        }
        if($id==0){
            return $data;
        }else{
        return $producto; }   
        }
        
        public function filtrarProductos($params) {
        $sql = "call sp_filtrarProductosVenta(?,?,?,?,?)";
        $query = $this->db->query($sql, $params);
        if ($query->num_rows() > 0) {
            foreach ($query->result() as $fila) :
                $data[] = $fila;
            endforeach;
        }else {
            $data = null;
        }
        return $data;
    }
        
   }
